package thread;

import com.sun.org.apache.xpath.internal.operations.String;
import thread.CustomThreadPool;
import thread.MyThread;

import java.util.concurrent.*;

public class AsyncThread {
    private final static ExecutorService e = new ThreadPoolExecutor(
            10,
            100,
            10,
            TimeUnit.SECONDS,
            new ArrayBlockingQueue<>(10)
    );
    private final ExecutorService e1 = Executors.newCachedThreadPool();

    private final ExecutorService e2 = Executors.newScheduledThreadPool(10);

    private final ExecutorService e3 = Executors.newSingleThreadExecutor();

    private final ExecutorService e4 = Executors.unconfigurableExecutorService(new ForkJoinPool(10));

    //
    private final ExecutorService e5 = Executors.newFixedThreadPool(10);

    // 自定义线程池
    private static final CustomThreadPool e6 = new CustomThreadPool("myThread");

    private static Object obj = new Object();


    public static void main(String[] args) {

        e6.newThread(()->{

        });

        obj = new String();
        Double d = 12.3654;

        try {
            for (int i = 0; i < 100; i++) {
                e.execute(new MyThread(i));
            }
        }
        catch (Exception ex){
            ex.printStackTrace();
        }finally {
            e.shutdown();
        }
    }
}
